import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  /** 路由按原型顺序排列,不做的模块不展示 */
  /** 1.系统设置 */
  /** 2.日志管理 */
  /** 3.用户管理 */
  /** 4.车辆管理 */
  /** 5.订单管理 */
  /** 6.员工管理 */
  /** 7.路段管理 */
  {
    path: '/road',
    component: Layout,
    redirect: '/road/list',
    name: '路段管理',
    meta: { title: '路段管理', icon: 'example' },
    children: [
      {
        path: 'map',
        name: 'Map',
        component: () => import('@/views/map/map'),
        meta: { title: '地图', icon: 'tree' }
      },
      {
        path: 'list',
        name: '路段列表',
        component: () => import('@/views/road/index'),
        meta: { title: '路段列表', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/road/add'),
        meta: { title: '添加', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/road/add'),
        meta: { title: '修改', icon: 'tree' },
        hidden: true
      },
      {
        path: 'list/:id',
        name: 'List',
        component: () => import('@/views/berth/list'),
        meta: { title: '泊位管理 ', icon: 'tree' },
        hidden: true
      }
    ]
  },
   {
    path: '/berth',
    component: Layout,
    redirect: '/berth/list',
    name: '泊位管理',
    meta: { title: '泊位管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '泊位列表',
        component: () => import('@/views/berth/index'),
        meta: { title: '泊位列表', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/berth/add'),
        meta: { title: '添加', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/berth/add'),
        meta: { title: '修改', icon: 'tree' },
        hidden: true
      }
    ]
  },
  /** 8.反馈管理 */
  /** 9.财务管理 */
  /** 10.统计管理 */
  {
    path: '/userfeedback',
    component: Layout,
    redirect: '/userfeedback/list',
    name: '用户反馈单管理',
    meta: { title: '用户反馈单管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '用户反馈单列表',
        component: () => import('@/views/userfeedback/index'),
        meta: { title: '用户反馈单列表', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/userfeedback/add'),
        meta: { title: '添加', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/userfeedback/add'),
        meta: { title: '修改', icon: 'tree' },
        hidden: true
      },
      {
        path: 'result/:id',
        name: 'Result',
        component: () => import('@/views/userfeedback/result'),
        meta: { title: '处理结果 ', icon: 'tree' },
        hidden: true
      }
    ]
  },
  /** 2.日志管理 */
  {
    path: '/log',
    component: Layout,
    redirect: '/log/list',
    name: 'logLogin',
    meta: { title: '日志管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/log/loginLog'),
        meta: { title: '登录日志', icon: 'table' }
      },
      {
        path: 'modifyPassword',
        name: 'modifyPassword',
        component: () => import('@/views/log/modifyPassword'),
        meta: { title: '修改密码', icon: 'table' },
        hidden: true
      }
    ]
  },
  /** 3.用户管理 */
  {
    path: '/user',
    component: Layout,
    redirect: '/user/manage',
    name: 'usermanage',
    meta: { title: '用户管理', icon: 'example' },
    children: [
      {
        path: 'manage',
        name: 'manage',
        component: () => import('@/views/usermanage/index'),
        meta: { title: '用户管理', icon: 'table' }
      }
    ]
  },
  /** 4.车辆管理 */
  {
    path: '/car',
    component: Layout,
    redirect: '/car/manage',
    name: 'usermanage',
    meta: { title: '车辆管理', icon: 'example' },
    children: [
      {
        path: 'manage',
        name: 'manage',
        component: () => import('@/views/car/index'),
        meta: { title: '车辆管理', icon: 'table' }
      }
    ]
  },
  /** 巡检员管理 */
  {
    path: '/inspector',
    component: Layout,
    redirect: '/inspector/manage',
    name: 'inspector',
    meta: { title: '巡检员管理', icon: 'example' },
    children: [
      {
        path: 'manage',
        name: 'manage',
        component: () => import('@/views/inspector/index'),
        meta: { title: '巡检员管理', icon: 'table' }
      }
    ]
  },
  {
    path: '/form',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index',
        name: 'Form',
        component: () => import('@/views/form/index'),
        meta: { title: 'Form', icon: 'form' }
      }
    ]
  },
  /** 5.订单管理 */
  {
    path: '/order',
    component: Layout,
    redirect: '/order/list',
    name: 'Order',
    meta: { title: '订单管理', icon: 'order' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/order/index'),
        meta: { title: '订单管理', icon: 'list' }
      },
      {
        path: 'exception',
        name: 'Exception',
        component: () => import('@/views/order/exception'),
        meta: { title: '异常订单', icon: 'exception' }
      },
      {
        path: 'detail',
        name: 'Detail',
        component: () => import('@/views/order/detail'),
        meta: { title: '订单详情', icon: 'exception' },
        hidden: true
      },
      {
        path: 'exceptionDetail',
        name: 'ExceptionDetail',
        component: () => import('@/views/order/exceptionDetail'),
        meta: { title: '异常订单详情', icon: 'exception' },
        hidden: true
      }
    ]
  },
  /** 6.员工管理 */
  {
    path: '/employee',
    component: Layout,
    redirect: '/employee/list',
    name: 'employee',
    meta: { title: '员工管理', icon: 'example' },
    children: [
      {
        path: 'manage',
        name: 'manage',
        component: () => import('@/views/operator/index'),
        meta: { title: '运维人员管理', icon: 'table' }
      }
    ]
  },
  // 9.财务管理 资金流水
  {
    path: '/fundFlow',
    component: Layout,
    redirect: '/fundFlow/list',
    name: 'FundFlow',
    meta: { title: '财务管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/fundFlow/index'),
        meta: { title: '资金流水', icon: 'table' }
      }
    ]
  },
  {
    path: '/inspectorfeedback',
    component: Layout,
    redirect: '/inspectorfeedback/list',
    name: '巡检员反馈单管理',
    meta: { title: '巡检员反馈单管理', icon: 'example' },
    children: [
      {
        path: 'list',
        name: '巡检员反馈单列表',
        component: () => import('@/views/inspectorfeedback/index'),
        meta: { title: '巡检员反馈单列表', icon: 'table' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/inspectorfeedback/add'),
        meta: { title: '添加', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: 'Edit',
        component: () => import('@/views/inspectorfeedback/add'),
        meta: { title: '修改', icon: 'tree' },
        hidden: true
      },
      {
        path: 'result/:id',
        name: 'Result',
        component: () => import('@/views/inspectorfeedback/result'),
        meta: { title: '处理结果 ', icon: 'tree' },
        hidden: true
      }
    ]
  },
  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: 'Nested',
      icon: 'nested'
    },
    hidden: true,
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: 'Menu1' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: 'Menu1-1' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'Menu1-2',
            meta: { title: 'Menu1-2' },
            children: [
              {
                path: 'menu1-2-1',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                name: 'Menu1-2-1',
                meta: { title: 'Menu1-2-1' }
              },
              {
                path: 'menu1-2-2',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                name: 'Menu1-2-2',
                meta: { title: 'Menu1-2-2' }
              }
            ]
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: { title: 'Menu1-3' }
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        meta: { title: 'menu2' }
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
